package com.cy2;

/**
 * @author CY
 * @date 2022/08/12 17:18
 **/
public class Test2 {
    protected void fun(){
        System.out.println(25);

    }
    public static void main(String[] args) {
        String s = ", , , ,        a, eaefa";
        System.out.println(countSegments(s));

    }

    public String toLowerCase(String s) {
        //   String s1 =  s.toLowerCase();
        //  return s1;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (Character.isUpperCase(ch)) {
                sb.append(Character.toLowerCase(ch));
                continue;
            }
            sb.append(ch);
        }
        return sb.toString();
    }

    public static int countSegments(String s) {
        if (s.length() == 0) {
            return 0;
        }
        int count = 0;
        String[] arr = s.split(" ");
        for (int i = 0; i < arr.length; i++) {
            if (arr[i].length() == 0) {
                ;
            } else {
                count++;
            }
        }
        return count;
    }
}
